home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1995 April / Internet Tools.iso / dos_win / winsock / packages / powertcp.exe / TCPEX.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-02-16  |  11.4 KB  |  344 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    Caption         =   "TCP Example"
  4.    ClientHeight    =   5820
  5.    ClientLeft      =   1272
  6.    ClientTop       =   1596
  7.    ClientWidth     =   7368
  8.    Height          =   6192
  9.    Icon            =   TCPEX.FRX:0000
  10.    Left            =   1224
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   5820
  13.    ScaleWidth      =   7368
  14.    Top             =   1272
  15.    Width           =   7464
  16.    Begin CommandButton cmdExit 
  17.       Caption         =   "E&xit"
  18.       Height          =   375
  19.       Left            =   120
  20.       TabIndex        =   14
  21.       Top             =   120
  22.       Width           =   1215
  23.    End
  24.    Begin Frame Frame3 
  25.       Caption         =   "Connected &From"
  26.       Height          =   3855
  27.       Left            =   3720
  28.       TabIndex        =   13
  29.       Top             =   1800
  30.       Width           =   3495
  31.       Begin PowerTCP_TCP tcpConnectFrom 
  32.          Flags           =   0
  33.          Left            =   720
  34.          LocalDotAddr    =   ""
  35.          OemLicense      =   ""
  36.          RemoteHost      =   ""
  37.          RemotePort      =   7
  38.          Top             =   360
  39.       End
  40.       Begin CommandButton cmdConnectFromSend 
  41.          Caption         =   "Se&nd"
  42.          Enabled         =   0   'False
  43.          Height          =   375
  44.          Left            =   2160
  45.          TabIndex        =   20
  46.          Top             =   720
  47.          Width           =   1215
  48.       End
  49.       Begin TextBox txtConnectFromSend 
  50.          Height          =   375
  51.          Left            =   120
  52.          TabIndex        =   19
  53.          Top             =   720
  54.          Width           =   1935
  55.       End
  56.       Begin CommandButton cmdConnectFromClose 
  57.          Caption         =   "Clo&se"
  58.          Enabled         =   0   'False
  59.          Height          =   375
  60.          Left            =   2160
  61.          TabIndex        =   16
  62.          Top             =   240
  63.          Width           =   1215
  64.       End
  65.       Begin TextBox txtConnectFrom 
  66.          FontBold        =   0   'False
  67.          FontItalic      =   0   'False
  68.          FontName        =   "Fixedsys"
  69.          FontSize        =   10.8
  70.          FontStrikethru  =   0   'False
  71.          FontUnderline   =   0   'False
  72.          Height          =   2535
  73.          Left            =   120
  74.          MultiLine       =   -1  'True
  75.          ScrollBars      =   2  'Vertical
  76.          TabIndex        =   15
  77.          Top             =   1200
  78.          Width           =   3255
  79.       End
  80.    End
  81.    Begin Frame Frame2 
  82.       Caption         =   "&Listen"
  83.       Height          =   1455
  84.       Left            =   3720
  85.       TabIndex        =   0
  86.       Top             =   120
  87.       Width           =   3495
  88.       Begin PowerTCP_TCP tcpListen 
  89.          Flags           =   0
  90.          Left            =   540
  91.          LocalDotAddr    =   ""
  92.          OemLicense      =   ""
  93.          RemoteHost      =   ""
  94.          RemotePort      =   7
  95.          Top             =   960
  96.       End
  97.       Begin CommandButton cmdStop 
  98.          Caption         =   "&Stop"
  99.          Enabled         =   0   'False
  100.          Height          =   375
  101.          Left            =   2040
  102.          TabIndex        =   4
  103.          Top             =   840
  104.          Width           =   1215
  105.       End
  106.       Begin TextBox txtListenPort 
  107.          Height          =   375
  108.          Left            =   600
  109.          TabIndex        =   2
  110.          Text            =   "23"
  111.          Top             =   360
  112.          Width           =   1215
  113.       End
  114.       Begin CommandButton cmdListen 
  115.          Caption         =   "&Listen"
  116.          Height          =   375
  117.          Left            =   2040
  118.          TabIndex        =   3
  119.          Top             =   360
  120.          Width           =   1215
  121.       End
  122.       Begin Label Label3 
  123.          Caption         =   "&Port:"
  124.          Height          =   375
  125.          Left            =   120
  126.          TabIndex        =   1
  127.          Top             =   360
  128.          Width           =   1215
  129.       End
  130.    End
  131.    Begin Frame Frame1 
  132.       Caption         =   "Connect &To"
  133.       Height          =   4935
  134.       Left            =   120
  135.       TabIndex        =   5
  136.       Top             =   720
  137.       Width           =   3495
  138.       Begin PowerTCP_TCP tcpConnectTo 
  139.          Flags           =   0
  140.          Left            =   180
  141.          LocalDotAddr    =   ""
  142.          OemLicense      =   ""
  143.          RemoteHost      =   ""
  144.          RemotePort      =   7
  145.          Top             =   1200
  146.       End
  147.       Begin CommandButton cmdConnectToSend 
  148.          Caption         =   "&Send"
  149.          Enabled         =   0   'False
  150.          Height          =   375
  151.          Left            =   2160
  152.          TabIndex        =   18
  153.          Top             =   1800
  154.          Width           =   1215
  155.       End
  156.       Begin TextBox txtConnectToSend 
  157.          Height          =   375
  158.          Left            =   120
  159.          TabIndex        =   17
  160.          Top             =   1800
  161.          Width           =   1935
  162.       End
  163.       Begin CommandButton cmdConnectToClose 
  164.          Caption         =   "C&lose"
  165.          Enabled         =   0   'False
  166.          Height          =   375
  167.          Left            =   2160
  168.          TabIndex        =   11
  169.          Top             =   1200
  170.          Width           =   1215
  171.       End
  172.       Begin TextBox txtConnectToPort 
  173.          Height          =   375
  174.          Left            =   2040
  175.          TabIndex        =   9
  176.          Text            =   "23"
  177.          Top             =   600
  178.          Width           =   1335
  179.       End
  180.       Begin TextBox txtConnectToAddress 
  181.          Height          =   375
  182.          Left            =   120
  183.          TabIndex        =   7
  184.          Text            =   "x.x.x.x"
  185.          Top             =   600
  186.          Width           =   1335
  187.       End
  188.       Begin CommandButton cmdConnect 
  189.          Caption         =   "&Connect"
  190.          Height          =   375
  191.          Left            =   720
  192.          TabIndex        =   10
  193.          Top             =   1200
  194.          Width           =   1215
  195.       End
  196.       Begin TextBox txtConnectTo 
  197.          FontBold        =   0   'False
  198.          FontItalic      =   0   'False
  199.          FontName        =   "Fixedsys"
  200.          FontSize        =   10.8
  201.          FontStrikethru  =   0   'False
  202.          FontUnderline   =   0   'False
  203.          Height          =   2535
  204.          Left            =   120
  205.          MultiLine       =   -1  'True
  206.          ScrollBars      =   2  'Vertical
  207.          TabIndex        =   12
  208.          Top             =   2280
  209.          Width           =   3255
  210.       End
  211.       Begin Label Label2 
  212.          Caption         =   "&Port:"
  213.          Height          =   495
  214.          Left            =   2040
  215.          TabIndex        =   8
  216.          Top             =   360
  217.          Width           =   1215
  218.       End
  219.       Begin Label Label1 
  220.          Caption         =   "&Address:"
  221.          Height          =   495
  222.          Left            =   120
  223.          TabIndex        =   6
  224.          Top             =   360
  225.          Width           =   1215
  226.       End
  227.    End
  228. ' IMPORTANT: We MUST use the API MessageBox function
  229. ' instead of the VB MsgBox function. See the PowerTCP
  230. ' README for more information.
  231. Declare Function MessageBox Lib "User" (ByVal hWnd As Integer, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Integer) As Integer
  232. Sub cmdConnect_Click ()
  233.     ' Set the properties of the remote computer
  234.     tcpConnectTo.RemoteHost = txtConnectToAddress.Text
  235.     tcpConnectTo.RemotePort = Val(txtConnectToPort.Text)
  236.     ' Make the connection
  237.     tcpConnectTo.Action = CONNECT
  238. End Sub
  239. Sub cmdConnectFromClose_Click ()
  240.     tcpConnectFrom.Action = CLOSECOMM
  241. End Sub
  242. Sub cmdConnectFromSend_Click ()
  243.     tcpConnectFrom.Send = txtConnectFromSend.Text
  244. End Sub
  245. Sub cmdConnectToClose_Click ()
  246.     tcpConnectTo.Action = CLOSECOMM
  247. End Sub
  248. Sub cmdConnectToSend_Click ()
  249.     tcpConnectTo.Send = txtConnectToSend.Text
  250. End Sub
  251. Sub cmdExit_Click ()
  252.     tcpConnectTo.Action = ABORTCOMM
  253.     tcpListen.Action = ABORTCOMM
  254.     tcpConnectFrom.Action = ABORTCOMM
  255.     End
  256. End Sub
  257. Sub cmdListen_Click ()
  258.     ' Set the mode of tcpListen to Listen
  259.     tcpListen.LocalPort = Val(txtListenPort.Text)
  260.     tcpListen.Action = LISTEN
  261. End Sub
  262. Sub cmdStop_Click ()
  263.     tcpListen.Action = CLOSECOMM
  264. End Sub
  265. Sub Form_Unload (Cancel As Integer)
  266.     End
  267. End Sub
  268. Sub tcpConnectFrom_Connect ()
  269.     cmdConnectFromClose.Enabled = True
  270.     cmdConnectFromSend.Enabled = True
  271. End Sub
  272. Sub tcpConnectFrom_Exception (ErrorCode As Integer, ErrorDesc As String)
  273.     ' An unexpected error occurred--
  274.     ' notify the user and close the connection
  275.     suc% = MessageBox(Me.hWnd, ErrorDesc, App.Title, 0)
  276.     tcpConnectFrom.Action = CLOSECOMM
  277. End Sub
  278. Sub tcpConnectFrom_Recv (RecvData As String)
  279.     If RecvData = "" Then
  280.         suc% = MessageBox(Me.hWnd, "The connection was closed.", App.Title, 0)
  281.         cmdConnectFromClose.Enabled = False
  282.         cmdConnectFromSend.Enabled = False
  283.     Else
  284.         txtConnectFrom.Text = txtConnectFrom.Text & Chr$(13) & Chr$(10) & Format$(tcpConnectFrom.RemoteHost) & ":" & Chr$(9) & RecvData
  285.     End If
  286. End Sub
  287. Sub tcpConnectFrom_Send (SendInstance As Long)
  288.     ' Clear the text box to let the user know
  289.     ' the data was sent
  290.     txtConnectFrom.Text = txtConnectFrom.Text & Chr$(13) & Chr$(10) & "Me:" & Chr$(9) & txtConnectFromSend.Text
  291.     txtConnectFromSend.Text = ""
  292. End Sub
  293. Sub tcpConnectTo_Connect ()
  294.     ' Make the Connect button disabled,
  295.     ' and the Close and Send buttons enabled.
  296.     cmdConnect.Enabled = False
  297.     cmdConnectToClose.Enabled = True
  298.     cmdConnectToSend.Enabled = True
  299. End Sub
  300. Sub tcpConnectTo_Exception (ErrorCode As Integer, ErrorDesc As String)
  301.     ' An unexpected error occurred--
  302.     ' notify the user
  303.     suc% = MessageBox(Me.hWnd, ErrorDesc, App.Title, 0)
  304. End Sub
  305. Sub tcpConnectTo_Recv (RecvData As String)
  306.     If RecvData = "" Then
  307.         ' The connection was closed
  308.         cmdConnect.Enabled = True
  309.         cmdConnectToClose.Enabled = False
  310.         cmdConnectToSend.Enabled = False
  311.         suc% = MessageBox(Me.hWnd, "The connection was closed.", App.Title, 0)
  312.     Else
  313.         txtConnectTo.Text = txtConnectTo.Text & Chr$(13) & Chr$(10) & Format$(tcpConnectTo.RemoteHost) & ":" & Chr$(9) & RecvData
  314.     End If
  315. End Sub
  316. Sub tcpConnectTo_Send (SendInstance As Long)
  317.     ' Clear the text box to let the user know
  318.     ' the data was sent
  319.     txtConnectTo.Text = txtConnectTo.Text & Chr$(13) & Chr$(10) & "Me:" & Chr$(9) & txtConnectToSend.Text
  320.     txtConnectToSend.Text = ""
  321. End Sub
  322. Sub tcpListen_Accept (NewSession As Long)
  323.     ' We must pass the connection on to tcpConnectFrom
  324.     If tcpConnectFrom.State = CLOSED Then tcpConnectFrom.Session = NewSession
  325. End Sub
  326. Sub tcpListen_Exception (ErrorCode As Integer, ErrorDesc As String)
  327.     ' An unexpected error occurred--
  328.     ' notify the user and close the connection
  329.     suc% = MessageBox(Me.hWnd, ErrorDesc, App.Title, 0)
  330.     tcpListen.Action = CLOSECOMM
  331. End Sub
  332. Sub tcpListen_Listen ()
  333.     ' Make the Listen button disabled,
  334.     ' and the Stop button enabled.
  335.     cmdListen.Enabled = False
  336.     cmdStop.Enabled = True
  337. End Sub
  338. Sub tcpListen_Recv (RecvData As String)
  339.     ' The connection was closed
  340.     cmdStop.Enabled = False
  341.     cmdListen.Enabled = True
  342.     suc% = MessageBox(Me.hWnd, "Listening was stopped.", App.Title, 0)
  343. End Sub
  344.